package com.one.common.view.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.one.common.R;
import com.one.common.utils.StringUtils;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/27 8:36 PM
 * description ：
 **/
public class StepItem extends RelativeLayout {

    private TextView tvStep;
    private View line;
    private ImageView ivStep;

    public StepItem(@NonNull Context context) {
        super(context, null);
        init(context, null);
    }

    public StepItem(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }


    public StepItem(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private void init(Context context, AttributeSet attrs) {
        LayoutInflater.from(context).inflate(R.layout.item_step, this);
        tvStep = findViewById(R.id.tv_step);
        ivStep = findViewById(R.id.iv_o);
        line = findViewById(R.id.line);

    }

    public void setText(String text) {
        if (StringUtils.isNotBlank(text)) {
            tvStep.setText(text);
        }
    }

    public void setText(int text) {
        if (text != -1) {
            tvStep.setText(text);
        }
    }

    public void setLineColor(int color){
        if(color!=-1){
            line.setBackgroundColor(getResources().getColor(color));
        }
    }

    public void setImage(int imgRes){
        if(imgRes != -1){
            ivStep.setImageResource(imgRes);
        }
    }

    public void setTextColor(int color){
        if(color!=-1){
            tvStep.setTextColor(getResources().getColor(color));
        }
    }


}
